/**
 * Created by novem on 2015/10/26.
 */
window.onload=function() {
    var url = getUrl();
    var userId=getUserId();
    $.jsonp({
        url: 'http://'+url+'/api/collect/collect_photobook_list',
        data: {userId:userId},
        callbackParameter: "callback",
        success: function (data, textStatus, xOptions) {
            $.each(data.arrays,function(index,ele) {
                var unixTimestamp = new Date(ele.createTime * 1000);
                ele.createTime = unixTimestamp.toLocaleString();
            });
            var complied_tpl = juicer($("#sc_tpl").text());
            var html = complied_tpl.render(data);
            $(".order-list").append(html);
        },
        error: function (xOptions, textStatus) {
        }
    });
//收藏
    $(document).on('click','.edit',function(){
        var obj=this;
        var samewayId=$(this).data('sc');
        $.jsonp({
            url: 'http://'+url+'/api/collect/collect_photobook',
            data: {photobookId:samewayId,userId:userId},
            callbackParameter: "callback",
            success: function (data, textStatus, xOptions) {
                   location.reload();
            },
            error: function (xOptions, textStatus) {
            }
        });
    });
}